home *** CD-ROM | disk | FTP | other *** search
- Path: gwen.pcug.co.uk!altheim!broldham
- Newsgroups: comp.lang.c
- Message-ID: <1247@altheim.win-uk.net>
- References: <1239@altheim.win-uk.net><4iklpm$28s@sparcserver.lrz-muenchen.de>
- Reply-To: broldham@altheim.win-uk.net (Brian R. Oldham)
- From: broldham@altheim.win-uk.net (Brian R. Oldham)
- Date: Wed, 20 Mar 1996 23:00:04 GMT
- Subject: Re: Pointers to register
-
-
- In article <4iklpm$28s@sparcserver.lrz-muenchen.de>, Kurt Watzka (watzka@stat.uni-muenchen.de) writes:
- >broldham@altheim.win-uk.net (Brian R. Oldham) writes:
- >
- >>A couple of weeks ago someone posted the opinion that all objects in
- >>memory must have an address, which might have gone uncontested but for
- >>the fact that he added that therefore all pointers must point to an
- >>address. Someone else reminded us that registers don't have an address.
- >
- >>Bearing in mind the usual way to assign a pointer:
- >
- >> ptr = &var;
- >
- >>is correct for objects in memory, but how do you assign a pointer
- >>to a register?
- >
- >>The following function (a getch() for x86) works: But is it right??
- >>
- >>/* Read next keystroke */
- >>#include <dos.h>
- >
- >>#define KEYBD 0x16
- >
- >>static union REGS inregs, outregs;
- >
- >>void getkey(int *scancode, char *ch)
- >>{
- >> inregs.h.ah = 0x00;
- >> int86(KEYBD,&inregs,&outregs);
- >
- >You use two structs that are members of a union to communicate with
- >a function that knows how to deal with them. This does not mean that
- >you are "taking the address of a register".
- >
- >"inregs" and "outregs" are variables in your program. Try:
- >
- > {
- > union REGS foo, bar, baz, bam;
- > }
- >
- >Those variables are in no way related to any registers.
- >
- >Kurt
- >--
-
- Yes Kurt, I think I've got the message by now. But where you guys keep
- missing the point (like Nottm Forest kept missing the Bayern Munich
- goalposts :-{ ) is that if declaration:
-
- *ptr = var;
-
- is wrong for other objects in memory then why does it work for:
-
- *ptr = union_member;
-
- And why does my compiler complain at the correct way:
-
- ptr = &union_member;
-
-
- ---
- Brian Oldham
- Hucknall UK
- !...Gesundbrunnen
-
-
-
-
-
-
-
-
-